﻿using ServiceStack.Redis;
using System.Configuration;

namespace DBBase
{
    sealed class RedisConnection
    {
        private static string _connectionString = "";
        public static string connectionString
        {
            get
            {
                if (string.IsNullOrEmpty(_connectionString)) _connectionString = ConfigurationManager.AppSettings["RedisConnection"];
                return _connectionString;
            }
        }

        private static PooledRedisClientManager _pool;
        public static PooledRedisClientManager pool
        {
            get
            {
                if (_pool == null)
                {
                    _pool = new PooledRedisClientManager(new string[] { connectionString }, new string[] { connectionString }, new RedisClientManagerConfig()
                    {
                        MaxReadPoolSize = 1000,
                        MaxWritePoolSize = 1000,
                        AutoStart = true
                    });
                    _pool.ConnectTimeout = 500;
                }
                return _pool;
            }
        }
    }
}
